
#ifndef _MEMBER_BTREEWIDGET_H_
#define _MEMBER_BTREEWIDGET_H_

#include <BImage>
#include <BStyle>
#include <BScrollBar>
#include <BScrollArea>
#include <BTreeItem>
#include <BTreeWidget>

#define tree_member(tree)		((member_BTreeWidget*)((BTreeWidget*)tree)->_ptr)

namespace BWE
{
	class member_BTreeWidget
	{
	public:
		member_BTreeWidget(BTreeWidget* treeWidget);
		~member_BTreeWidget();
		
		void dirtyItem(BTreeItem* item);
		void freshWidget(BTreeItem* item, bool visual);

		bool freshArea();
		void freshItemRect(const BStyle* style, const BFont* font, BTreeItem* item, int x, int& y, BSize& areaSize);
		void freshVisualItems();
		void adjustVisualItem(BTreeItem* item, const BPoint& offset, const BRect& crect, const BSize& areaSize);
		bool collectPrevItems(BTreeItem* item, BTreeItem* lastItem, BTreeItemArray& collectedItems);
		bool collectNextItems(BTreeItem* item, BTreeItem* lastItem, BTreeItemArray& collectedItems);

		void expandAll(BTreeItem* item);
		void shrinkAll(BTreeItem* item);

		BTreeWidget*			boss;
		int						indent;
		BSize					arrowSize;
		Align					arrowAlign;
		bool					arrowVisible;
		int						itemSpacing;
		BSize					itemSize;
		Align					itemAlign;
		Policy					itemPolicy;
		SelectMode				selectMode;
		BIconHolder				expandIcon;
		BIconHolder				shrinkIcon;
		BHolder<const BStyle>	itemStyle;

		bool					dirty;
		bool					dirtyVisual;
		BSize					realArrowSize;
		int						realSpacing;
		int						realIndent;
		bool					pressed;
		bool					hoveredArrow;
		BTreeItem*				hoveredItem;
		BArray<BTreeItem*>		selectedItems;
		BArray<BTreeItem*>		visualItems;
		BArray<BTreeItemHolder>	items;
	};
}
#endif